﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace VASMide
{
    public partial class start : Form
    {
        public start()
        {
            InitializeComponent();
        }
        List<string> realDirs = new List<string>();
        private void start_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            if (File.Exists("mru.txt"))
            {
                StreamReader sr = new StreamReader("mru.txt");
                string s = sr.ReadToEnd();
                listBox1.Items.Clear();
                foreach (string f in (s.Replace("\r", "")).Split('\n'))
                {
                    if (!realDirs.Contains(f))
                    {
                        if (Directory.Exists(f))
                        {
                            listBox1.Items.Add(f.Substring(f.LastIndexOf('\\') + 1));
                            realDirs.Add(f);
                        }
                    }
                }
                sr.Close();
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            startForm sf = new startForm();
            sf.TopMost = true;
            sf.Show();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                startForm.loadProject(realDirs[listBox1.SelectedIndex]);
            }
            catch
            {
                // Do nothing , the user must have not clicked on a project file.
            }
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
            folderBrowserDialog1.SelectedPath = Application.StartupPath;
            folderBrowserDialog1.ShowDialog();
            startForm.loadProject(folderBrowserDialog1.SelectedPath); 
        }
    }
}
